package com.yzy.controller;

import com.yzy.dao.AdminDao;
import com.yzy.dao.PatientDao;
import com.yzy.utils.Utils;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class PatientLonginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pphone,ppass,booktime;

        PatientDao dao = new PatientDao();
        int result=0;
        //1utf-8
        request.setCharacterEncoding("utf-8");
        //2读取请求体参数
        pphone = request.getParameter("pphone");
        ppass = request.getParameter("ppass");
        booktime = request.getParameter("booktime");





        //3调用dao
        result = dao.longin(pphone,ppass);
        System.out.println(result);
        //4调用响应对象
        if(result==1){

            response.sendRedirect("/myWeb/patient/book");


        }else{
            System.out.println(result);
            response.sendRedirect("/myWeb/adminlongin_error.html");
        }
        ServletContext application = request.getServletContext();
        application.setAttribute("PlonginPhone1",pphone);
        application.setAttribute("booktime",booktime);
    }
}
